Skip to content

路線選択時に前回の列車種別データが残るバグを修正#5352

Merged
TinyKitten merged 1 commit intodevfrom
fix/traintype-list
Feb 19, 2026
Merged

路線選択時に前回の列車種別データが残るバグを修正#5352
TinyKitten merged 1 commit intodevfrom
fix/traintype-list

Conversation

@TinyKitten
Copy link
Member

@TinyKitten TinyKitten commented Feb 19, 2026

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

Summary by CodeRabbit

リリースノート

  • Bug Fixes
    • ラインおよびステーション選択時の状態更新プロセスを改善し、データ取得がより確実に反映されるよう修正しました。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@TinyKitten TinyKitten self-assigned this Feb 19, 2026
@github-actions github-actions bot added the react label Feb 19, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 19, 2026

📝 Walkthrough

Walkthrough

SelectLineScreen.tsxのlineSelection関連メソッドにおいて、pendingStationおよびpendingStationsの状態管理フローが改変されました。handleLineSelectedとopenModalByLineIdの両メソッドで、ステーション情報をクリアしてから再度フェッチして再入力する2段階更新パターンが導入されました。

Changes

Cohort / File(s) Summary
State Reset and Refetch Logic
src/screens/SelectLineScreen.tsx
handleLineSelectedおよびopenModalByLineIdメソッドにおいて、pendingStationとpendingStationsの状態をクリア後に再度フェッチして再入力する2段階更新フローを追加。初期状態のリセットに続いて新規データで状態を更新する構造に変更。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

react

Poem

🐰 ステーション情報、クリアして再び

取り直すダンス、二段階の美しさ

ウサギも喜ぶ、整理された流れ

🎣✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed プルリクエストのタイトルは、路線選択時に前回の列車種別データが残るバグの修正という、変更内容の主要な目的を明確に要約している。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/traintype-list

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/screens/SelectLineScreen.tsx (1)

565-596: ⚠️ Potential issue | 🟠 Major

最新のリクエストのみを反映させるガードが必要

Line 584-596 の非同期フェッチ中に再度カード選択されると、古いレスポンスで状態が上書きされる可能性があります。fetchStationsByLineIdLoading が true のときはスケルトンで保護されますが、フェッチ完了後に再び CommonCard が表示される際、CommonCard の loading プロップは onPress を無効化しません。そのため以下のシナリオが発生します:

  1. 線A を選択 → フェッチ開始
  2. フェッチ完了 → fetchStationsByLineIdLoading が false に
  3. CommonCard 再表示(モーダル開いたまま)
  4. 線B を選択 → 別フェッチ開始
  5. 線B のレスポンスが後に到着 → 線A のデータを上書き

Line 592-596 の状態更新時に lineId の一致をチェックするか、フェッチ中はカードへのタップを無効化する対策を検討してください。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/screens/SelectLineScreen.tsx` around lines 565 - 596, Save the current
requested lineId into a local variable before calling fetchStationsByLineId
(e.g. const requestLineId = lineId) and after the await return, check that the
response matches the latest selected line (compare requestLineId to the current
pending/selected line id from state, e.g. lineState.pendingLine?.id or
stationState.pendingStation?.lineId) and abort setting
pendingStation/pendingStations if they differ; alternatively also disable
CommonCard onPress while fetchStationsByLineIdLoading is true so taps are
ignored during an ongoing fetch. Ensure you update the code around setLineState,
fetchStationsByLineId and the setStationState block to perform this guard.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/screens/SelectLineScreen.tsx`:
- Around line 565-596: Save the current requested lineId into a local variable
before calling fetchStationsByLineId (e.g. const requestLineId = lineId) and
after the await return, check that the response matches the latest selected line
(compare requestLineId to the current pending/selected line id from state, e.g.
lineState.pendingLine?.id or stationState.pendingStation?.lineId) and abort
setting pendingStation/pendingStations if they differ; alternatively also
disable CommonCard onPress while fetchStationsByLineIdLoading is true so taps
are ignored during an ongoing fetch. Ensure you update the code around
setLineState, fetchStationsByLineId and the setStationState block to perform
this guard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant